<?php

namespace System\library\database\sql;

/**
 * <b>Class</b> :        SqlServer<br>
 * <b>Fonction</b> :     Permet la configuration et gestion de server SQL
 * <br>
 * @version              1.0
 * @author               Steuf <dreadlokeur@gmail.com>
 * @license              Licence publique générale GNU http://www.gnu.org/licenses/gpl.html
 * @copyright            Copyright 2011 - MidichloriansPHP and contributors
 * @package              System
 * @subpackage           library\database\sql
 */
class SqlServer {

    private $_host = null;
    private $_port = null;
    private $_login = '';
    private $_password = '';
    private $_database_name = null;
    private $_dsn = null;

    public function __construct() {
        
    }

    public function setHost($host) {
        if (!is_string($host))
            throw new \Exception('Hostname doit être une chaine');
        $this->_host = $host;
        return $this;
    }

    public function setLogin($login) {
        if (!is_string($login))
            throw new \Exception('Login doit être une chaine');
        $this->_login = $login;
        return $this;
    }

    public function setPassword($password) {
        if (!is_string($password))
            throw new \Exception('Password doit être une chaine');
        $this->_password = $password;
        return $this;
    }

    public function setPort($port) {
        $port = (int) $port;
        if ($port < 1 || $port > 65535)
            throw new \Exception('Port doit être entre 1 et 65535');
        $this->_port = $port;
        return $this;
    }

    public function setDatabaseName($name) {
        if (!is_string($name))
            throw new \Exception('Database name doit être une chaine');
        $this->_database_name = $name;
        return $this;
    }

    public function setDsn($dsn) {
        if (!is_string($dsn))
            throw new \Exception('Dsn doit être une chaine');
        $this->_dsn = $dsn;
        return $this;
    }

    public function getDsn() {
        return $this->_dsn;
    }

    public function getHost() {
        return $this->_host;
    }

    public function getLogin() {
        return $this->_login;
    }

    public function getPassword() {
        return $this->_password;
    }

    public function getPort() {
        return $this->_port;
    }

    public function getDatabaseName() {
        return $this->_database_name;
    }

}

